/*
 * @Date: 2023-11-08 13:08:29
 * @LastEditors: lyx
 * @LastEditTime: 2023-11-14 13:22:36
 * @FilePath: \sup-mimi-program-server\utils\mongo-crud\crud-config.ts
 * @Description:
 */
import { get, merge } from 'lodash';
import { CrudOptions } from './crud.interface';

export const defaultPaginate = {
  records: 'records', // 数据
  total: 'total', // 总条数
  current: 'current', // 当前页
  pages: 'pages', // 总页数
  size: 'size', // 每页条数
};

export class CrudConfig {
  public static options: CrudOptions = {
    routes: {
      find: {
        paginate: { ...defaultPaginate },
      },
    },
  };
  static setup(options: CrudOptions) {
    this.options = merge({}, this.options, options);
  }
  static get(key, defaultValue = undefined) {
    return get(this.options, key, defaultValue);
  }
}
